package com.xy.biz.base.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.base.domain.bo.AttachmentBO;
import com.xy.biz.base.domain.po.AttachmentPO;
import com.xy.biz.base.domain.query.AttachmentQuery;
import com.xy.biz.base.domain.resp.GetAttachmentResponse;
import com.xy.biz.base.domain.req.SaveAttachmentRequest;
import com.xy.biz.base.domain.req.ListAttachmentRequest;

/**
 *
 *
 * @author wwj
 * @date 2021-4-6
 */
public class AttachmentConverter {

	public static AttachmentPO toPO(AttachmentBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new AttachmentPO(), true);
	}

	public static List<AttachmentPO> toPO(Collection<AttachmentBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new AttachmentPO(), true);
	}

	public static AttachmentBO fromPO(AttachmentPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new AttachmentBO());
	}

	public static List<AttachmentBO> fromPO(Collection<AttachmentPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new AttachmentBO());
	}

	public static AttachmentBO toBO(SaveAttachmentRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new AttachmentBO(), true);
	}

	public static List<AttachmentBO> toBO(Collection<SaveAttachmentRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new AttachmentBO(), true);
	}

	public static GetAttachmentResponse toResponse(AttachmentBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetAttachmentResponse());
	}

	public static List<GetAttachmentResponse> toResponse(Collection<AttachmentBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetAttachmentResponse());
	}

	public static AttachmentQuery toQuery(ListAttachmentRequest source) {
		if(null == source) {
			return null;
		}
		AttachmentQuery target = AttachmentQuery.max().build();
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
